package com.xl.myEnum;

import lombok.AllArgsConstructor;
import lombok.Data;

import java.util.ArrayList;

/**
 * 用户参与类型枚举类
 * 用户参与类型，1机车司机 2运转车长 3随车机械师 4 其他用户（可扩充）
 */
@AllArgsConstructor
public enum ParticipantTypeEnum {

	LOCOMOTIVE_DRIVER(1, "机车司机"),
	RUNNING_CAPTAIN(2, "运转车长"),
	CAR_MECHANIC(3, "随车机械师"),
	OTHER_USER(4, "其他用户");

	private Integer type;

	private String info;

	public static String getInfoByType(Integer provideType) {
		for (ParticipantTypeEnum value : values()) {
			if (value.type.equals(provideType)) {
				return value.info;
			}
		}
		throw new RuntimeException("暂不支持该用户类型");
	}

	public static Integer getTypeByInfo(String provideInfo) {
		for (ParticipantTypeEnum value : values()) {
			if (value.info.equals(provideInfo)) {
				return value.type;
			}
		}
		throw new RuntimeException("暂不支持该用户类型");
	}


	public static String[] getAllEnumInfo() {
		ArrayList<String> arrayList = new ArrayList();
		for (ParticipantTypeEnum value : values()) {
			arrayList.add(value.info);
		}
		return arrayList.toArray(new String[]{});
	}
}
